﻿using System;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using YJKRevitView;

namespace YJKRevitAxisModule
{
	[Transaction(TransactionMode.Manual)]
	[Regeneration(RegenerationOption.Manual)]
	public class CmdMain_AuxiliaryConversion : IExternalCommand
	{
		public Result Execute(ExternalCommandData cmdData, ref string msg, ElementSet elems)
		{
			CmdViewType types = (CmdViewType)11;
			if (SwitchView.SetUsableView(types, cmdData) != Autodesk.Revit.UI.Result.Succeeded)
			{
				return Autodesk.Revit.UI.Result.Failed;
			}
			Result result2;
			try
			{
				if (cmdData == null)
				{
					throw new System.ArgumentNullException("commandData");
				}
				Document document = cmdData.Application.ActiveUIDocument.Document;
				MainAuxiliaryConversion mainAuxiliaryConversion = new MainAuxiliaryConversion(cmdData);
				Result result;
				do
				{
					result = mainAuxiliaryConversion.Convert();
				}
                while (result == Autodesk.Revit.UI.Result.Succeeded);
				result2 = Autodesk.Revit.UI.Result.Succeeded;
			}
			catch (Exception ex)
			{
				msg = ex.Message;
				result2 = Autodesk.Revit.UI.Result.Failed;
			}
			return result2;
		}
	}
}
